package com.anche.demo.excel;



import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.anche.demo.entity.Product;
import lombok.Data;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;

/**
 * @ClassName: SimpleExcelTest
 * @Description: TODO
 * @date: 2023/2/8 17:38
 * @Auther: hey
 */
public class SimpleExcelTest {
    @Data
    @ColumnWidth(20) // 定义列宽
    public static class TestVO {
        @ExcelProperty(value = "*姓名", index = 0)
        private String name;
        @ExcelProperty(value = "*年龄", index = 1)
        private int age;
        @ExcelProperty(value = "学校", index = 2)
        private String school;
    }

    public static void main(String[] args) throws IOException {
        // 输出流
        OutputStream outputStream = new FileOutputStream(new File("C:\\Users\\Administrator\\Desktop\\ceshi.xlsm"));
        HashMap<Integer, String[]> dropDownMap = new HashMap<>();
        // 指定下拉框
        String[] school = {"一中","二中","三中"};
        dropDownMap.put(2,school);
        EasyExcelUtil.writeExcelWithModel(outputStream, TestVO.class, dropDownMap);
    }
}
